package com.hk.huakangcompany.mapper;

import com.hk.huakangcompany.model.LoginLog;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author zhe
 * @Create 2021/7/30/14:10
 * @State 登录日志数据持久层
 */
public interface LoginLogMapper extends BaseMapper<LoginLog> {

    @Override
    List<LoginLog> findAll(LoginLog loginLog);

    @Override
    int count(LoginLog loginLog);

    @Select("select * from login_log where id = #{id} ")
    @Override
    LoginLog findById(Integer id);

    @ApiOperation("保存登录日志")
    @Override
    int save(LoginLog loginLog);

    @ApiOperation("保存登出时间")
    @Update("update login_log set " +
            "   gmt_modified=#{gmtModified},state=#{state} " +
            "   where id = #{id} ")
    @Override
    int update(LoginLog loginLog);

    @Delete("delete from login_log where id = #{id} ")
    @Override
    int delete(Integer id);

    @Delete("delete from login_log ORDER BY id ASC LIMIT #{count} ")
    int deleteLimit(Integer count);

}
